<?php

namespace App\Clients\Keruyun;

use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Database\Eloquent\Model;

class StoreQueryBillCompleted extends KeruyunClient
{
    public function __construct(Model $account){
        parent::__construct($account);
        $this->queryData = [
            'group' => 'HSF',
            '@class' => 'com.alsc.saas.gw.client.HsfReq',
            'service' => 'com.alsc.saas.fund.merchant.client.api.FundBillFacade',
            'method' => 'queryBillCompleted',
            'version' => '1.0.0',
            'eagleEyeUserData' => new \stdClass(),
            'argTypes' => [
                'com.alsc.saas.fund.merchant.client.request.bill.QueryFundBillCompletedRequest'
            ],
            'argValues' => [
                [
                    'billNo' => 'B074453498'
                ]
            ],
            'targetClusterName' => 'alibaba-prod',
            'timeout' => 'PT30S',
            'context' => [
                'visitedDevice' => 'WEB'
            ]
        ];
//        var_dump(json_encode($this->queryData));
//        exit();
    }

    public function handleQueryData($queryData)
    {
        $this->queryData["argValues"] = [
            [
                'billNo' => $queryData["billNo"]
            ]
        ];
//        var_dump($this->queryData["argValues"]);
//        exit();
    }


    /**
     * @throws GuzzleException
     */
    public function execute($queryData = []): StoreQueryBillCompleted
    {
//        var_dump(json_encode($queryData));
//        exit();
        return $this->post("https://saas.keruyun.com/saas-gw/secure/v2/req?hsfApi=queryBillCompleted",$queryData);
    }
}
